#! /usr/bin/env python3
# 控制器
# 文件名: base.py
import web

import json

import time

from apps.library.Db.Db import Db

class base:
    def __init__(self):
        #实例化db
        self.db = Db()

    def getQuery(self):
        str = web.input()
        return str
    
    def postQuery(self):
        str = web.input()
        return str

    def outputNormal(self, data, message = "成功", code = 1):
        option = {
            'isSuccess' : True,
            'code' : code,
            'response' : data,
            'message' : message,
            'ts' : time.time()
        }
        return json.dumps(option)

    def outputError(self, data, message = "失败", code = 1):
        option = {
            'isSuccess' : False,
            'code' : code,
            'response' : data,
            'message' : message,
            'ts' : time.time()
        }
        return json.dumps(option)

